﻿using System;
using System.Collections.Generic;

namespace Components.Data.Fields
{
  public class FieldCollection : List<Field>
  {
    public Field this[String key]
    {
      get
      {
        return this.Find(f => f.Key == key.ToLowerInvariant());
      }
      set
      {
        Field field = this.Find(f => f.Key == key.ToLowerInvariant());

        if (field != null)
        {
          field = value;
          return;
        }
        this.Add(value);
      }
    }
  }
}